package ca.venasse.pinventory.part.query;

import javax.persistence.AttributeOverride;
import javax.persistence.Column;
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.Id;

import org.axonframework.domain.AggregateIdentifier;
import org.axonframework.domain.StringAggregateIdentifier;

import ca.venasse.pinventory.common.Category;
import ca.venasse.pinventory.common.Name;

@Entity(name = "PART")
public class PartEntity {

	@Id
	@Column(length = 36, nullable = false, updatable = false)
	private String aggregateIdentifier;

	@Embedded
	@AttributeOverride(name = "value", column = @Column(name = "category"))
	private Category category;

	@Embedded
	@AttributeOverride(name = "value", column = @Column(name = "name"))
	private Name name;

	protected PartEntity() {
	}

	public PartEntity(AggregateIdentifier aggregateIdentifier) {
		this.aggregateIdentifier = aggregateIdentifier.asString();
	}

	public AggregateIdentifier getAggregateIdentifier() {
		return new StringAggregateIdentifier(this.aggregateIdentifier);
	}

	public Category getCategory() {
		return this.category;
	}

	public Name getName() {
		return this.name;
	}

	public void setCategory(Category category) {
		this.category = category;
	}

	public void setName(Name name) {
		this.name = name;
	}

}
